using System;
using Microsoft.Web.Management.Client;
using Microsoft.Web.Management.Client.Extensions;
using Microsoft.Web.Management.Server;

namespace LeastPrivilege.CustomBasicAuthentication.Management
{
    // the module registers the custom UI with InetMgr
    public class CustomBasicAuthenticationModule : Module
    {
        protected override void Initialize(IServiceProvider serviceProvider, ModuleInfo moduleInfo)
        {
            base.Initialize(serviceProvider, moduleInfo);

            // add our module to the authentication section in the GUI
            IExtensibilityManager manager = 
                (IExtensibilityManager)serviceProvider.GetService(typeof(IExtensibilityManager));
            
            if (manager != null)
            {
                manager.RegisterExtension(
                    typeof(AuthenticationFeature), 
                    new CustomBasicAuthenticationFeature(this));
            }
        }
    }
}
